package com.gdust.gkyx.acl.controller;

import com.gdust.gkyx.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * ClassName: IndexController
 * Package: com.gdust.gkyx.acl.controller
 * Description:改造登录功能
 *
 * @Author syun
 * @Create 2025/1/21 10:08
 * @Version 1.0
 */
@Api(tags = "登录接口")
@RestController // @RestController: 专用于restful风格的注解 = @Controller (控制器) + @ResponseBody (方法返回值为json)
@RequestMapping("/admin/acl/index")
//@CrossOrigin //跨域
public class IndexController {

    /**
     * //1 login登录
     *  //   http://localhost:8201/admin/acl/index/login
     * @return
     */
    @ApiOperation("登录")
    @PostMapping("login")
    public Result login() {
        //返回token值
        Map<String,String> map = new HashMap<>();
        map.put("token","token-admin");
        return Result.ok(map);
    }


    /**
     * //2 getInfo 获取信息
     * //    url: '/admin/acl/index/info',
     * //    method: 'get',
     * @return
     */
    @ApiOperation("获取信息")
    @GetMapping("info")
    public Result info() {
        Map<String,String> map = new HashMap<>();
        map.put("name","admin");
        map.put("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        return Result.ok(map);
    }

    /**
     * //3 logout 退出
     *  //    url: '/admin/acl/index/logout',
     *  //    method: 'post'
     * @return
     */
    @ApiOperation("退出")
    @PostMapping("logout")
    public Result logout() {
        return Result.ok(null);
    }

}
